/*     */ package com.qmsk.business.order.orderDetail.controller;
/*     */ 
/*     */ import com.qmsk.business.manage.cust.dao.CustDAO;
/*     */ import com.qmsk.business.order.orderDetail.dao.OrderDetailDao;
/*     */ import com.qmsk.business.order.orderMain.dao.OrderMainDao;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/orderDt"})
/*     */ public class OrderDetailController
/*     */ {
/*  36 */   private static final Logger logger = Logger.getLogger(OrderDetailController.class);
/*     */ 
/*     */   @Autowired
/*     */   private OrderDetailDao dao;
/*     */ 
/*     */   @Autowired
/*     */   private CustDAO custDao;
/*     */ 
/*     */   @Autowired
/*     */   private OrderMainDao mianDao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getorderDetailOfMIdList(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  61 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*  62 */     String openId = RequestUtils.getString(request, "openId", null);
/*  63 */     Long mId = RequestUtils.getLong(request, "mId", Long.valueOf(0L));
/*     */     try {
/*  65 */       GsonEbRst g = null;
/*  66 */       if (mId.longValue() > 0L) {
/*  67 */         g = this.dao.getorderDetailOfMIdList(mId, nPageIdx, nPageSize);
/*     */       } else {
/*  69 */         Long custId = null;
/*  70 */         if (StringUtils.isNotEmpty(openId)) {
/*  71 */           custId = this.custDao.getCustIdOfOpenId(openId, shopId);
/*     */         }
/*  73 */         if (custId.longValue() > 0L) {
/*  74 */           mId = this.mianDao.isExsitOrderMain(custId, openId, shopId);
/*  75 */           if (mId.longValue() > 0L) {
/*  76 */             g = this.dao.getorderDetailOfMIdList(mId, nPageIdx, nPageSize);
/*     */           }
/*     */         }
/*     */       }
/*  80 */       if ((g != null) && 
/*  81 */         (!(g.isExistsData()))) {
/*  82 */         g = null;
/*     */       }
/*     */ 
/*  85 */       ResponseUtils.setResponseResult(g, response);
/*     */     } catch (SQLException e) {
/*  87 */       logger.error(e);
/*  88 */       ResponseUtils.setErrorMsgResponse(
/*  89 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/dtCount"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getDtCount(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  97 */     Long shopId = RequestUtils.getLong(request, "shopId", Long.valueOf(0L));
/*  98 */     String openId = RequestUtils.getString(request, "openId", null);
/*     */     try {
/* 100 */       GsonEbRst g = null;
/* 101 */       Long custId = null;
/* 102 */       Long mId = null;
/* 103 */       if (StringUtils.isNotEmpty(openId)) {
/* 104 */         custId = this.custDao.getCustIdOfOpenId(openId, shopId);
/*     */       }
/* 106 */       if (custId.longValue() > 0L) {
/* 107 */         mId = this.mianDao.isExsitOrderMain(custId, openId, shopId);
/* 108 */         if (mId.longValue() > 0L) {
/* 109 */           g = this.dao.getDtCount(mId);
/*     */         }
/*     */       }
/*     */ 
/* 113 */       if ((g != null) && 
/* 114 */         (!(g.isExistsData()))) {
/* 115 */         g = null;
/*     */       }
/*     */ 
/* 118 */       ResponseUtils.setResponseResult(g, response);
/*     */     } catch (SQLException e) {
/* 120 */       logger.error(e);
/* 121 */       ResponseUtils.setErrorMsgResponse(
/* 122 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 135 */     Long dtId = RequestUtils.getLong(request, "dtId", Long.valueOf(0L));
/* 136 */     Long goodsId = RequestUtils.getLong(request, "goodsId", Long.valueOf(0L));
/*     */     try {
/* 138 */       GsonHeadOneRow g = new GsonHeadOneRow(new String[] { "orderDtId", "goodsID" }, new Object[] { dtId, goodsId });
/* 139 */       int nResult = this.dao.deletePkGsonHeadOneRow(g, "crm_orderdetail");
/* 140 */       if ((nResult > 0) && (!(this.dao.getDtIdIsDt(dtId)))) {
/* 141 */         nResult = this.mianDao.deleteParams(new Object[] { dtId });
/*     */       }
/* 143 */       if (nResult > 0)
/* 144 */         DbConnection.commit();
/*     */       else {
/* 146 */         DbConnection.rollback();
/*     */       }
/* 148 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 149 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 150 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 153 */       DbConnection.rollback();
/* 154 */       logger.error(e);
/* 155 */       ResponseUtils.setErrorMsgResponse(
/* 156 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 157 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 175 */       int nResult = 0;
/* 176 */       String sData = RequestUtils.getStringOfData(request);
/* 177 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 178 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 179 */         nResult = this.mianDao.applyUpdates(p);
/*     */       }
/* 181 */       if ((nResult > 0) || (p == null) || (p.isExistsRows())) {
/* 182 */         ParserDataSetJson pgdsPrice = 
/* 183 */           ParserDataSetJson.fromString(RequestUtils.getString(request, 
/* 184 */           "detailData"));
/* 185 */         if ((pgdsPrice != null) && (pgdsPrice.isExistsRows())) {
/* 186 */           nResult = this.dao.applyUpdates(pgdsPrice);
/*     */         }
/*     */       }
/* 189 */       if (nResult > 0)
/* 190 */         DbConnection.commit();
/*     */       else {
/* 192 */         DbConnection.rollback();
/*     */       }
/* 194 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 195 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 196 */         response);
/*     */     } catch (Exception e) {
/* 198 */       logger.error(e.getMessage());
/* 199 */       DbConnection.rollback();
/* 200 */       ResponseUtils.setErrorMsgResponse(
/* 201 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 202 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.order.orderDetail.controller.OrderDetailController
 * JD-Core Version:    0.5.3
 */